<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    {$XUaCompatible}
    <title></title>
    <link href="{$Css}style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
    <div class="con">
        <div id="logo"><a href="{$Url}welcome" title="{$CMSName}后台" target="main">{CMSName}后台</a></div>
        <!--menu start-->
        <div id="menu">
            <div class="item">
                <ul>
                    <volist name="MenuTop" id="m" key="i">
                        <if condition="$m.IsActive eq '1'">
                            <li class="index"><a href="{$Group}/{$m.MenuTopUrl}/MenuTopID/{$m.MenuTopID}" id="item{$m.MenuTopID}" target="{$m.MenuTopTarget}" mid="{$m.MenuTopID}" class="active" onclick="Tabmenu(this,{$m.MenuTopID});">{$m.MenuTopName}</a></li>
                        <else/>
                            <li><a href="{$Group}/{$m.MenuTopUrl}/MenuTopID/{$m.MenuTopID}" id="item{$m.MenuTopID}" target="{$m.MenuTopTarget}"  mid="{$m.MenuTopID}" onclick="Tabmenu(this,{$m.MenuTopID});">{$m.MenuTopName}</a></li>
                        </if>
                    </volist>
                </ul>
            </div>
        </div>
        <!--menu start-->
        <notempty name="Language">
            <div id="language">
              <div>
                    <ul>
                        <volist name="Language" id="l">
                            <li>
                                <a <eq name="l.LanguageMark" value="$AdminLanguageMark">class="active"</eq>  onclick="ChangeLng(this,'{$l.LanguageMark}','{$Url}','lng{$l.LanguageID}')" target="main">{$l.LanguageName}</a>
                            </li>
                        </volist>
                    </ul>
              </div>
            </div>
        </notempty>
    </div>
</div>
<script type="text/javascript" src="{$WebPublic}jquery/jquery-1.7.2.min.js"></script>
<script>
$(document).ready(function() {
	$(document).keydown(function(e) {
		window.parent.frames['main'].keyHandler(e);
	});
	
	var n = "{$MenuTopID}";
	var curitem = document.getElementById("item"+n);
	Tabmenu(curitem, n);
});

function ChangeLng(obj,mark,url,id){
	var Items = document.getElementById("language").getElementsByTagName("a");
	for(var i= 0,len = Items.length;i<len;++i){
		if(Items[i].clssName !==""){
			Items[i].className = "";
		}
	}
	obj.className = "active";
	
	//获取当前顶层菜单ID
	var mid = 0;
	var Items = document.getElementById("menu").getElementsByTagName("a");
	for(var i= 0,len = Items.length;i<len;++i){
		if(Items[i].className == "active"){
			mid = Items[i].getAttribute('mid');
			break;
		}
	}
	
	if(mid == 3){ //内容频道需要刷新左侧菜单
		RefreshChannel(obj,mark);
	}else{
		RefreshMain(obj,mark);
	}
}

function RefreshChannel(obj,mark){
	var t = new Date().getTime();
	var url = window.parent.frames["menu"].location.href;
	var p = url.indexOf("/l/");
	if( p > 0){
	  url = url.substring(0, p);
	}
	obj.target = "menu";
	obj.href = url+"/l/"+mark+"/random/"+t;
	var mainUrl = window.parent.frames["main"].location.href;
	var objUrl = "{$Url}welcome";
	var index = mainUrl.toLowerCase().indexOf( objUrl.toLowerCase()  );
	if( index == -1  ){
		window.parent.frames["main"].location.href = "{$Url}welcome";
	}
	return true;
}

function RefreshMain(obj,mark){
	var t = new Date().getTime();
	var url = window.parent.frames["main"].location.href;
	var p = url.indexOf("/l/");
	if( p > 0){
	  url = url.substring(0, p);
	}
	obj.target = "main";
	obj.href = url+"/l/"+mark+"/random/"+t;
	return true;
}


function Tabmenu(obj,n){
	$("#menu a").removeClass("active");
	$(obj).addClass("active");
	location.hash = n;
	return true;
};
</script>
</body>
</html>